Add preflight checks at start of each reconciliation loop#367
Merged
Add preflight checks at start of each reconciliation loop#367
Conversation
mahlunar
approved these changes
Apr 27, 2026
4 tasks
Verify controller assumptions before any side-effecting work: - the database connection is alive - the connecting user is a member of the configured superuser role The role defaults to rds_superuser (RDS's conventional admin role) and can be overridden for non-RDS deployments via --superuser-role-name. On failure the error names the violated assumption so operators can act on it. Wired into PostgreSQLDatabaseReconciler and CustomRoleReconciler. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d04c278 to
7659b91
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rds_superuser(withrolsuperas a fallback for non-RDS test environments)PostgreSQLDatabaseReconcilerandCustomRoleReconciler; the latter gains aManagerRoleNamefield fed by the existing--manager-role-nameflag.Test plan
go build ./...andgo vet ./...passgo test ./pkg/postgres/...(non-integration) passesPOSTGRESQL_CONTROLLER_INTEGRATION_HOST=... go test ./pkg/postgres/... -run TestPreflightcovers sunshine, empty manager role, missing manager role, unprivileged user🤖 Generated with Claude Code
Note
Medium Risk
Adds new preflight gating to
PostgreSQLDatabaseandCustomRolereconciliation; misconfiguration (missing manager role, insufficient privileges, replica host) will now cause reconciles to fail early and retry, potentially blocking provisioning until fixed.Overview
Introduces a new
postgres.Preflightcheck that validates controller prerequisites (reachable DB, writable primary, sufficient admin privileges, and existence of the configured management role) and returns explicit operator-facing errors.Wires these checks into the start of each
PostgreSQLDatabaseReconcilerandCustomRoleReconcilerloop (including a newrunPreflighthelper for databases), and plumbs--manager-role-nameintoCustomRoleReconcilerfromcmd/main.go.Adds integration tests covering the passing case and key failure modes (empty manager role, missing role, and under-privileged user).
Reviewed by Cursor Bugbot for commit ba40568. Configure here.